package com.kizuki.design.chain;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class PhoneVerify extends Verify{

    public static final String REGEX = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";

    /**
     * 检验手机号码
     * @param userAccount
     */
    @Override
    protected VerifyResult handle(UserAccount userAccount) {
        String phone = userAccount.getPhone();
        boolean isPhone = phone.matches(REGEX);
        log.info("校验客户手机号码, phone:{}, isPhone:{}", phone, isPhone);
        return VerifyResult.buildResult(isPhone, "客户手机格式有误");
    }
}
